import {defineConfig} from 'vite';
import vue from '@vitejs/plugin-vue';
// 导入path模块
import path from 'path'; // 使用import导入解决错误
// 解决语法糖导包
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: ['vue', 'vue-router'],
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  css: {  // 配置less
    preprocessorOptions: {
      less: {
        math: "always"
      }
    }
  },
  // base: '/dist',  // 打包路径
  // base: '/qing-shu/static/dist/',  // 打包路径
  server: {
    port: 80, // 设置服务启动端口号
    // https: true,
    // host: '0.0.0.0', // 允许所有ip访问
  },
  resolve: {
    // 配置路径别名
    alias: {
      '@': path.resolve(__dirname, './src'),
    }
  },
  // 设置代理 - 后端数据接口
  devServer: {
    proxy: {
      '/api': import.meta.env,
      changeOrigin: true,
    },
  },
});
